/*
 *  Copyright © 2014 CIB Co.Ltd
 *  * All right reserved
 *  * Auther:jin xingwang
 *
 */

package com.wsd.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 模块
 * @author 靳兴旺
 * @version 1.0.0 2020-7-17
 * 将拦截器添加到列表中，即观察者与被观察者
 */

@Configuration
public class WebRequestInterceptor extends WebMvcConfigurerAdapter {

    @Autowired
    private WebInterceptor webInterceptor;

    /** 需要拦截的url */
    @Value("${jwt.secret-url}")
    private String jwtSecreUrl;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        jwtSecreUrl = jwtSecreUrl.replaceAll(" ", "");
        registry.addInterceptor(webInterceptor).addPathPatterns(jwtSecreUrl.split(","));
    }
}
